﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.IoC;
using Kooboo.Domain;

namespace Kooboo.Commerce.Domain.Services
{
    public class ProductImageService:ServiceBase<IProductImageRepository,IProductImage>
    {
        //internal ProductImageService()
        //{
        //}

        public override IQueryable<IProductImage> QueryService
        {
            get
            {
                return this.Repository.ProductImages;
            }
        }

        #region ProductImage
        public void Post(IProductImage productImage)
        {
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Post(productImage);
                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Put(IProductImage productImage)
        {
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Put(productImage);
                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Delete(IProductImage productImage)
        {
            

            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Delete(productImage);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        #endregion
    }

}
